import { Controller, Get, Post, Body, Patch, Param, Request, Delete } from '@nestjs/common'
import { TodolistService } from './todolist.service'
import { UpdateTodolistDto } from './dto/update-todolist.dto'
import { CustomRequest } from 'src/type'

@Controller('todolist')
export class TodolistController {
  constructor(private readonly todolistService: TodolistService) {}

  @Post()
  create(@Body() body: any, @Request() req: CustomRequest) {
    return this.todolistService.create(body, req)
  }

  // 获取所有待办列表
  @Get()
  findAll(@Request() req: CustomRequest) {
    return this.todolistService.findAll(req)
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.todolistService.findOne(+id)
  }

  // 是否完成待办
  @Patch(':id')
  update(@Param('id') id: string, @Body() updateTodolistDto: UpdateTodolistDto) {
    return this.todolistService.update(+id, updateTodolistDto)
  }

  // 删除待办
  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.todolistService.remove(+id)
  }
}
